package red.uec.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import red.uec.model.*;
import red.uec.service.UserService;

import javax.validation.Valid;

@RestController
@RequestMapping("/password")
public class PasswordController {
    @Autowired
    private UserService userService;

    @PutMapping(value = "/modification")
    public PasswordModificationResponse modify(@Valid PasswordModificationRequest passwordModificationRequest){
        return userService.modifyPassword(passwordModificationRequest);
    }

    @PostMapping("/reset/message_code")
    public PasswordResetMessageCodeResponse getResetMessageCode(@Valid PasswordResetMessageCodeRequest passwordResetMessageCodeRequest){
        return userService.getPasswordResetMessageCode(passwordResetMessageCodeRequest);
    }

    @PutMapping("/reset")
    public PasswordResetResponse reset(@Valid PasswordResetRequest passwordResetRequest){
        return userService.resetPassword(passwordResetRequest);
    }
}
